package views
{
	import caurina.transitions.Equations;
	import caurina.transitions.Tweener;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.events.TimerEvent;
	import flash.utils.Timer;
	import models.MainModel;
	import models.types.SectionType;
	import org.osflash.signals.Signal;
	import views.components.Section;
	import caurina.transitions.properties.ColorShortcuts;
	
	ColorShortcuts.init();

	public class RingsView extends Sprite
	{
		private var rings_sprite:Sprite;
		
		public static var instance:RingsView;
		
		public var ringsDrawed:Signal;
		
		public function RingsView():void
		{
			instance = this;
			
			rings_sprite = new Sprite();
			
			addChild(rings_sprite);
			
			MainModel.instance.sectionsAssigned.add(placeRings);
		}
		
		private function placeRings():void
		{
			var ring1:Ring1MC = new Ring1MC();
			var ring2:Ring2MC = new Ring2MC();
			var ring3:Ring3MC = new Ring3MC();
			
			rings_sprite.addChild(ring1).alpha = 0;
			rings_sprite.addChild(ring2).alpha = 0;
			rings_sprite.addChild(ring3).alpha = 0;
			
			ringRotate(ring1, -360, 4);
			ringRotate(ring2, 360, 13);
			
			ringFade(ring1, 1);
			Tweener.addTween(this, { time:0.2, onComplete: ringFade, onCompleteParams: [ring2, 1]} );
			Tweener.addTween(this, { time:0.4, onComplete: ringFade, onCompleteParams: [ring3, 1] } );
			
			Tweener.addTween(this, { time:1, onComplete: ringsFadingComplete } );
		}
		
		private function ringsFadingComplete():void
		{
			Main.instance.menu_view.create();
		}
		
		private function ringRotate(mc:Sprite, angle:Number, tm:Number):void
		{
			Tweener.addTween(mc, { rotation: angle , time:tm, transition:Equations.easeNone, onComplete: ringRotate, onCompleteParams:[mc, angle, tm] } );
		}
		
		private function ringFade(mc:Sprite, val:Number):void
		{
			Tweener.addTween(mc, { alpha: val, time:1, transition:Equations.easeNone } );
		}
	}
	
}